<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head> 
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
	<title>湖南省自来水公司营销管理信息系统</title> 
	
	<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/text.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/form.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/buttons.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/grid.css" type="text/css" media="screen" title="no title" />	
	<link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" title="no title" />	
	
	<link rel="stylesheet" href="../css/ui-darkness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/jquery.visualize.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/facebox.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/uniform.default.css" type="text/css" media="screen" title="no title" />
	<link rel="stylesheet" href="../css/plugin/dataTables.css" type="text/css" media="screen" title="no title" />
	
	<link rel="stylesheet" href="../css/custom.css" type="text/css" media="screen" title="no title">

</head> 
 
<body> 

<div>
    <div id="qiqi"></div><script>window.onload = function(){$("#qiqi").load("../dropDownMenu.html")}</script>

	
	<div id="content"  class="xgrid">
		
 		
		<div id="app" class="x12">
			
			<h2>添加/修改附加费</h2>
			
			<div class="form label-inline uniform">
	
				<div class="field"><label for="id">附加费ID</label> <input id="id" name="fname" size="50" type="text" class="medium" disabled="disabled" value="自动生成" /></div>
				
				<div class="field"><label for="name">附加费编码</label> <input id="name" v-model="SyCostType.code" name="lname" size="50" type="text" class="medium" /></div>
				
				<div class="field"><label for="name">附加费简称</label> <input id="name" v-model="SyCostType.costTypeName" name="lname" size="50" type="text" class="medium" /></div>
				
				<div class="field"><label for="name">附加费全称</label> <input id="name" v-model="SyCostType.fullName" name="lname" size="50" type="text" class="medium" /></div>
				
				<div class="field"><label for="name">附加费单价</label> <input id="name" v-model="SyCostType.price" name="lname" size="50" type="text" class="medium" /> 元/吨</div>
				
				<div class="controlset field">

					<span class="label">征收范围</span>
					<div class="controlset-pad">
                        <div  v-for="c in SyCostTypes">
						<input type="checkbox" class="check1" :value="c.id" :checked="c.diskabled?'checked':''" />  <label v-text="c.costTypeName" for="check1">生活用水</label><br />
                        </div>

					</div>
				</div>	

							
				<div class="field"><label for="description">备注</label> <textarea rows="7" v-model="SyCostType.remark" cols="50" id="description" name="description"></textarea></div>

				<div class="buttonrow">
					<button class="btn" @click="cleck()">保存</button>
					<button class="btn btn-grey" onClick="history.back(-1);">返回</button>
				</div>

			</div>
			
		</div> <!-- .x12 -->
		
	</div> <!-- #content -->
	
	<div id="footer">		
		<div class="content_pad">			
			<p>&copy; 2013-11 版权所有 <a href="#">湖南省自来水公司</a>.   技术支持 <a href="#">职业教育</a>.</p>
		</div> <!-- .content_pad -->
	</div> <!-- #footer -->
	
</div> <!-- #wrapper -->

<script src="../js/jquery/jquery-1.5.2.min.js"></script>
<script src="../js/jquery/jquery-ui-1.8.12.custom.min.js"></script>
<script src="../js/misc/excanvas.min.js"></script>
<script src="../js/jquery/facebox.js"></script>
<script src="../js/jquery/jquery.visualize.js"></script>
<script src="../js/jquery/jquery.dataTables.min.js"></script>
<script src="../js/jquery/jquery.tablesorter.min.js"></script>
<script src="../js/jquery/jquery.uniform.min.js"></script>
<script src="../js/jquery/jquery.placeholder.min.js"></script>

<script src="../js/widgets.js"></script>
<script src="../js/dashboard.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
    var u = new URLSearchParams(location.search);
    var id = u.get('id');
    if(id != null && id != ""){
        $(function (){
            $.getJSON("/system/queryBySySurcharge",{"eid":id},function (json) {
               // alert(JSON.stringify(json))
                app.SySurcharges = json;
            })
        })
        $(function () {
            $.ajax({
                type:"get",
                data:"id="+parseInt(id),
                url:"/system/queryByidSyCostType",
                success:function (json){
                    $("#id").val(json.id)
                    //alert(JSON.stringify(json))
                    app.SyCostType = json;
                }
            })
        })
    }
    window.onload = function () {
        $.ajax({
            type:"get",
            dataType:"json",
            url:"/system/queryAllSyCostType",
            success:function (json) {
                app.SyCostTypes = json;
                $.each(app.SySurcharges,function (i,name) {
                    $.each(app.SyCostTypes,function () {
                        if(name.waterTypeId == this.id){
                            this.diskabled = true;
                        }
                    })
                })

            }
        })
    }
    var app = new Vue({
        el: '#app',
        data: {
            SySurcharges:"",
            SyCostTypes:"",
            ar:[],
            SyCostType:{
                id:"",
                kind:"1",
                code:"",
                costTypeName:"",
                fullName:"",
                price:"",
                surchargeText:"",
                remark:"",
                diskabled:"0",
            }
        },
        mounted() {
            // methods里面定义的方法, 需要赋值给window
            //window.del = this.del;
        },
        methods:{
            cleck(){
                var str = "";
                $(".check1").each(function (i,name) {
                    if(name.checked == true){
                        $.each(app.SyCostTypes,function () {
                            if(name.value == this.id){
                                app.ar.push(name.value);
                                str += this.costTypeName+",";
                            }
                        })
                    }
                })
                $.post("/system/saveSySurcharge",{"eid":app.SyCostType.id,"mid":app.ar.toString()},function () {});
                app.SyCostType.surchargeText = str.slice(0,-1);
                if(app.SyCostType.id == null || app.SyCostType.id == ""){
                    $.ajax({
                        type:"post",
                        data:app.SyCostType,
                        url:"/system/saveSyCostType",
                        success:function (json) {
                            location='sys_surcharge.html';
                        }
                    })
                }else{
                    $.ajax({
                        type:"put",
                        data:app.SyCostType,
                        url:"/system/updateSyCostType",
                        success:function (json) {
                            location='sys_surcharge.html';
                        }
                    })
                }

                //alert(JSON.stringify(app.SyCostType));
            }
        },watch:{
            SyCostTypes:function () {
                this.$nextTick(function () {
                    $(document).ready ( function (){
                        Dashboard.init ();
                    });
                })
            }
        },created(){//surchargeId;waterTypeId;
        }
    })
</script>

</body> 
 
</html>